package com.example.human_resource_management.controller;

import com.example.human_resource_management.common.ResponseData;
import com.example.human_resource_management.entry.dto.EmployeeForumAdminDto;
import com.example.human_resource_management.entry.po.EmployeeForum;
import com.example.human_resource_management.service.EmployeeForumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/admin/forum")
public class EmployeeForumAdminController {

    @Autowired
    private EmployeeForumService employeeForumService;

    // 管理员端查询所有论坛帖子
    @GetMapping("/list")
    public ResponseData<List<EmployeeForumAdminDto>> selectAllEmployeeForums() {
        List<EmployeeForumAdminDto> forums = employeeForumService.selectAllEmployeeForums();
        return ResponseData.ok(forums);
    }

    // 管理员端新增论坛帖子
    @PostMapping("/create")
    public ResponseData<String> adminCreateEmployeeForum(@RequestBody EmployeeForum employeeForum) {
        return employeeForumService.adminCreateEmployeeForum(employeeForum);
    }

    // 管理员端更新论坛帖子
    @PutMapping("/update")
    public ResponseData<String> adminUpdateEmployeeForum(@RequestBody EmployeeForum employeeForum) {
        return employeeForumService.adminUpdateEmployeeForum(employeeForum);
    }

    // 管理员端删除论坛帖子
    @DeleteMapping("/delete/{postId}")
    public ResponseData<String> adminDeleteEmployeeForum(@PathVariable Long postId) {
        return employeeForumService.adminDeleteEmployeeForum(postId);
    }
}